<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="../js/jquery-1.12.2.js"></script>
<title>登录</title>
</head>
<body>
	<div>
		<form class="cus-form">
			<table>
				<tr>
					<td><label>用户名：</label></td>
					<td><input type="text" name="username" id="username"></td>
				</tr>
				<tr>
					<td><label>密码：</label></td>
					<td><input type="password" name="password" id="password"></td>
				</tr>
				<tr>
					<td><input type="button" value="登录" onclick="login();"></td>
				</tr>
			</table>
		</form>
	</div>
	<script type="text/javascript">
		$(document).ready(function(){
	        //监听Enter按键 
	        $('body').keydown(function(e){
	            if(e.keyCode === 13){
	                login();
	            }
	        });
	    })
	
		function login() {
			$.ajax({
				url : 'login.do',
				data : $('form').serialize(),
				dataType : 'json',
				type : 'post',
				success : function(data) {
					if (data == true) { //登陆成功
						window.location.href = '${appName}/sys/index';
					} else {
						window.location.href = '${appName}/sys/error';
					}
				},
				error : function(){
					alert("数据发送失败！");
				}
			});
		}
	</script>
</body>
</html>